package org.ice4apps.master.dao;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Organization entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "organization", catalog = "icemaster", uniqueConstraints = @UniqueConstraint(columnNames = "name"))
public class Organization implements java.io.Serializable {
    // Fields
    private String        id;
    private Enterprise    enterprise;
    private String        name;
    private Long          features;
    private Long          creationdate;
    private Long          updationdate;
    private Set<Office>   offices   = new HashSet<Office> (0);
    private Set<OrgAdmin> orgAdmins = new HashSet<OrgAdmin> (0);

    // Constructors
    /** default constructor */
    public Organization () {
    }

    /** minimal constructor */
    public Organization (String id,
                         Enterprise enterprise,
                         String name,
                         Long creationdate) {
        this.id = id;
        this.enterprise = enterprise;
        this.name = name;
        this.creationdate = creationdate;
    }

    /** full constructor */
    public Organization (String id,
                         Enterprise enterprise,
                         String name,
                         Long features,
                         Long creationdate,
                         Long updationdate,
                         Set<Office> offices,
                         Set<OrgAdmin> orgAdmins) {
        this.id = id;
        this.enterprise = enterprise;
        this.name = name;
        this.features = features;
        this.creationdate = creationdate;
        this.updationdate = updationdate;
        this.offices = offices;
        this.orgAdmins = orgAdmins;
    }

    // Property accessors
    @Id
    @Column(name = "id", unique = true, nullable = false, length = 36)
    public String getId () {
        return this.id;
    }

    public void setId (String id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "enterprise", nullable = false)
    public Enterprise getEnterprise () {
        return this.enterprise;
    }

    public void setEnterprise (Enterprise enterprise) {
        this.enterprise = enterprise;
    }

    @Column(name = "name", unique = true, nullable = false, length = 36)
    public String getName () {
        return this.name;
    }

    public void setName (String name) {
        this.name = name;
    }

    @Column(name = "features")
    public Long getFeatures () {
        return this.features;
    }

    public void setFeatures (Long features) {
        this.features = features;
    }

    @Column(name = "creationdate", nullable = false)
    public Long getCreationdate () {
        return this.creationdate;
    }

    public void setCreationdate (Long creationdate) {
        this.creationdate = creationdate;
    }

    @Column(name = "updationdate")
    public Long getUpdationdate () {
        return this.updationdate;
    }

    public void setUpdationdate (Long updationdate) {
        this.updationdate = updationdate;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "organization")
    public Set<Office> getOffices () {
        return this.offices;
    }

    public void setOffices (Set<Office> offices) {
        this.offices = offices;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "organization")
    public Set<OrgAdmin> getOrgAdmins () {
        return this.orgAdmins;
    }

    public void setOrgAdmins (Set<OrgAdmin> orgAdmins) {
        this.orgAdmins = orgAdmins;
    }
}